const Koa = require('koa');
const app = new Koa();
const path = require('path');
const compose = require('koa-compose');
const koaBody = require('koa-body');
const helmet = require('koa-helmet');

const error_handler = require('./middlewares/error_handler.js'); // 模块化引入
const logger = require('./middlewares/logger.js');
//app.use(error_handler());
const not_found = require('./middlewares/not_found.js');

let all_middles = compose([error_handler, helmet, logger]);
app.use(all_middles);


const router = require('./libs/router.js');
router(app);

const post_middlewares = compose([not_found]);
app.use(post_middlewares);

app.on('error',(err, ctx)=>{
    console.log('server error', err);
});

app.listen(14355);
console.log("server port is: 14355 runing!")
